Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

866
Visualizações
ObjectParameterError: Parameter "filter" to find() must be an object, got search

this get route is giving no error in post-man but doing the same with frontend giving error in node console:

ObjectParameterError: Parameter "filter" to find() must be an object, got search

although response are fetched.

get controller

const Recent = require("../models/recent");
const getRecentByName = async (req, res, next) => {
  const name = req.params.name;
  let regex = new RegExp(name, "i");
  let players;
  try {
    players = await Recent.find({ name: { $regex: regex } });
  } catch (err) {
    return next(err);
  }
  if (!players) {
    return next("no player found");
  }
  // console.log(players);
  res.json({ players });
};  

exports.getRecentByName = getRecentByName;

fetching from frontend:

const searchRecords = async () => {
    const data = await sendRequest(
      "http://localhost:5000/api/player/recent/search/" + search,
      "GET"
    );

    setRecord(data.players);
  }; 

Recent:(mongoose Schema):

const mongoose = require("mongoose");

const Schema = mongoose.Schema;

const recentSchema = new Schema({
  name: { type: String, required: true },
  recent: [
    {
      team1: { type: String },
      team2: { type: String },
      points: { type: Number, required: true },
      date: { type: Date },
    },
  ],
});

module.exports = mongoose.model("Recent", recentSchema);
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

I think the problem is from the front and in the URL you should use http://localhost:5000/api/player/recent/search/${search}

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda